# Copyright (c) 2009 Daropia Project (www.daropia.org)
#
# This file is part of Daropia and is available under the terms
# of the GNU General Public Licence version 2.0 or later.


# Represents a Post

class Post < Sequel::Model
    # A post is owned by one topic
    many_to_one :topic

    # A post is owned by one user
    many_to_one :user
    
    def after_create
        super
        topic.increment_message_count
    end
    
    def after_destroy
        super
        topic.decrement_message_count
    end
    
    def html_content
        content.gsub("\n", "<br/>")
    end
    
end
